﻿using System.Collections.Generic;
using UnityEngine;
using System.Runtime.InteropServices;

//解析html的url得到token
public class GetURLInfo : MonoBehaviour
{

    [DllImport("__Internal")]
    private static extern string StringReturnValueFunction();

    public static string UrlMsg = string.Empty;
    public static string UrlToken = string.Empty;
    void Start()
    {
#if !UNITY_EDITOR && UNITY_WEBGL
        //获取url
        print("UNITY_WEBGL");
        UrlMsg = StringReturnValueFunction();
        
        //UrlMsg = "?token=AAABa7GNbEIBAAAAAAABh4I%3D.TRCHeQzNov41BXFrSsRWg5l8O6vuE0ncX0HN4I0fzcvIGq9ORYJasoYQGuRLn3j6uxtWZUrXFYfexYZHVfdPWG0JnbpB27Q5mOtsgWLFdL4%3D.DE0dQ2SjiLkCobG%2F0o2X%2Fj%2Bhga%2Bewv1UPgWLEF%2FCbJE%3D";
        Debug.Log("UrlMsg:" + UrlMsg);
        string[] arr = UrlMsg.Split('&');
        Dictionary<string, string> allMsg = new Dictionary<string, string>();
        for (int i = 0; i < arr.Length; i++)
        {
            allMsg.Add(arr[i].Split('=')[0], arr[i].Split('=')[1]);
            Debug.Log(arr[i].Split('=')[0] + "++++++" + arr[i].Split('=')[1]);
        }
        UrlToken = arr[0].Split('=')[1];
#endif
    }
}
